<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:fragment xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets" id="frag2">

	<p:tabView effect="slide" effectDuration="normal" widgetVar="tab"
		binding="#{vendaProdutoMB.tabFormaPagamento}" id="tabFormPgto">

		<p:tab title="#{lbls.LBL_0052}">

			<h:panelGrid columns="2">
				<p:outputLabel value="#{lbls.LBL_0049}:"
					for="txtTotalVendaDinheiroValor" />
				<p:inputText size="5" id="txtTotalVendaDinheiroValor"
					style="font:bold 15px arial,sans-serif;"
					value="#{vendaProdutoMB.formaPagamento.valorTotal}">
					<f:convertNumber pattern="#,##0.00" minFractionDigits="2" />
				</p:inputText>

				<p:outputLabel value="#{lbls.LBL_0053}:" for="txtValorRecebidoValor" />
				<p:inputText size="5" id="txtValorRecebidoValor"
					onblur="calcularTroco(#{vendaProdutoMB.venda.valor} , this.value);" />

				<p:outputLabel value="#{lbls.LBL_0054}:" for="txtTroco" />
				<p:inputText size="5" id="txtTroco" readonly="true" />
			</h:panelGrid>

		</p:tab>
		<p:tab title="#{lbls.LBL_0057}" disabled="true">

			<h:panelGrid columns="2">
				<h:outputText value="#{lbls.LBL_0049}:" />
				<p:inputText size="5" readonly="true" id="txtTotalVenda3"
					style="font:bold 25px arial,sans-serif;  "
					value="#{compraProdutoMB.formaPagamento.valorTotal}">
					<f:convertNumber type="currency" />
				</p:inputText>

				<h:outputText value="#{lbls.LBL_0053}:" />
				<p:inputText size="5" />

			</h:panelGrid>

		</p:tab>
		<p:tab title="#{lbls.LBL_0058}" disabled="true">
			<h:panelGrid columns="2">
				<h:outputText value="#{lbls.LBL_0049}:" />
				<p:inputText size="5" readonly="true" id="txtTotalVenda4"
					style="font:bold 25px arial,sans-serif; "
					value="#{compraProdutoMB.formaPagamento.valorTotal}">
					<f:convertNumber type="currency" />
				</p:inputText>

				<h:outputText value="#{lbls.LBL_0055}:" />
				<h:panelGroup>
					<p:inputText size="1" />
					<h:outputText value=" x " />
					<p:inputText size="3" />
				</h:panelGroup>

			</h:panelGrid>

		</p:tab>
		<p:tab title="#{lbls.LBL_0058}" disabled="true">
			<h:panelGrid columns="2">
				<h:outputText value="#{lbls.LBL_0049}:" />
				<p:inputText size="5" readonly="true" id="txtTotalVenda6"
					style="font:bold 25px arial,sans-serif;  "
					value="#{compraProdutoMB.formaPagamento.valorTotal}">
					<f:convertNumber type="currency" />
				</p:inputText>

				<h:outputText value="#{lbls.LBL_0055}:" />
				<h:panelGroup>
					<p:inputText size="1" />
					<h:outputText value=" x " />
					<p:inputText size="3" />
				</h:panelGroup>

			</h:panelGrid>
		</p:tab>
	</p:tabView>


	<p:commandButton id="btnAddFormaPgto" value="#{lbls.LBL_0009}"
		process="@this tabFormPgto"
		update="tabFormPgto formaPgtoDataTable btnSalvarVenda"
		action="#{vendaProdutoMB.doAdicionarFormaPagamento}"
		icon="ui-icon-plus" style="float: right; margin-top:5px;" />

	<p:spacer height="45px" />

	<p:dataTable id="formaPgtoDataTable" var="formaPgto" paginator="false"
		style="width:100%" emptyMessage="#{lbls.LBL_0004}" rows="4"
		value="#{vendaProdutoMB.venda.listaFormasPagamento}">

		<p:column>
			<h:outputText value="#{formaPgto.tipoPagamento.descricao}" />
			<f:facet name="footer">
				<h:outputText value="#{lbls.LBL_0075}:" />
			</f:facet>
		</p:column>

		<p:column style="width:1%;">
			<h:outputText value="#{formaPgto.qtdaParcelas}" />
		</p:column>

		<p:column style="width:100px;">
			<h:outputText value="#{formaPgto.valorParcela}">
				<f:convertNumber type="currency" />
			</h:outputText>
		</p:column>

		<p:column style="width:100px;">
			<h:outputText value="#{formaPgto.valorTotal}">
				<f:convertNumber type="currency" />
			</h:outputText>
			<f:facet name="footer">
				<h:outputText value="#{vendaProdutoMB.valorRestante }">
					<f:convertNumber type="currency" />
				</h:outputText>
			</f:facet>
		</p:column>

		<p:column style="width:1%;">
			<p:commandButton id="btnDelFormPgto" icon="ui-icon-trash" immediate="true"
				action="#{vendaProdutoMB.doRemoverFormaPagamento}"
				update="formaPgtoDataTable" process="@this">
				<f:setPropertyActionListener value="#{formaPgto}"
					target="#{vendaProdutoMB.formaPagamento}" />
			</p:commandButton>
		</p:column>

	</p:dataTable>
</ui:fragment>